<?php

namespace App\Http\Controllers\Api;

use App\Libraries\Taobao;
use App\Models\ItemsCate;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Redis;
use GuzzleHttp\Client;

class TestController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index(Request $request)
    {
//        $data = Taobao::getGoodsDetail('14440470877');
        $data = Taobao::getGoodsDetail('581054984990');
        echo "<pre>";
        print_r($data);
//        Taobao::getGoodsDetail('579503966256');
        die;
        //file_put_contents("./hadeswangtest88888.html",file_get_contents("http://mdetail.tmall.com/templates/pages/desc?id=14440470877"));

        if($request->del_goods_redis_cache == 1)
        {
            $all_cache_datas = Redis::smembers(env('ITEMS_CRAWLERED_COLLECTIONS_REDIS_KEY'));
            if(!empty($all_cache_datas))
            {
                foreach ($all_cache_datas as $k=>$v)
                {
                    Redis::srem(env('ITEMS_CRAWLERED_COLLECTIONS_REDIS_KEY'), $v);
                }
            }
            echo "del ok";
            die;
        }
    }
    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        //
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        //
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        //
    }

    public function apiTest()
    {
        $target = "2018-10-25";
        $r = createdAt($target);
        dd($r);
    }
}
